package com.chujiekeji.test.fragment;


import android.graphics.Color;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.CollapsingToolbarLayout;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.Gravity;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.chujiekeji.test.R;
import com.chujiekeji.test.adapter.BaseRecyclerAdapter;
import com.chujiekeji.test.adapter.FriendCircleAdapter;
import com.chujiekeji.test.adapter.friend.FenSiAdapter;
import com.chujiekeji.test.api.ChujieApi;
import com.chujiekeji.test.base.BaseFragment;
import com.chujiekeji.test.bean.FriendCircle;
import com.chujiekeji.test.bean.PageBean;
import com.chujiekeji.test.bean.ResultBean;
import com.chujiekeji.test.bean.friend.FenSi;
import com.chujiekeji.test.fragment.base.BaseRecyclerViewFragment;
import com.chujiekeji.test.util.SimplexToast;
import com.chujiekeji.test.util.TLog;
import com.google.gson.reflect.TypeToken;

import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.ViewInject;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * @author MapleStory
 * @ qq 1002285057
 * @ project https://gitee.com/MapStory/Shopwt-Android
 */
public class FriendCircleFragment extends BaseRecyclerViewFragment<FriendCircle> {
    @Override
    protected BaseRecyclerAdapter<FriendCircle> getRecyclerAdapter() {
        return new FriendCircleAdapter(getContext(), BaseRecyclerAdapter.ONLY_FOOTER);
    }

    @Override
    protected Type getType() {
        return new TypeToken<ResultBean<PageBean<FriendCircle>>>() {
        }.getType();
    }

    @Override
    protected void requestData() {
        super.requestData();
        ChujieApi.fetchFriendCircle(isRefreshing ? 1 : (mBean.getNextPage()==null?1:mBean.getNextPage()),20,mHandler);
        TLog.i("FriendCircle","onFinish");
    }

    @Override
    public void setUserVisibleHint(boolean isVisibleToUser) {
        super.setUserVisibleHint(isVisibleToUser);
        isRefreshing = true;
        if (isCreated && isVisibleToUser){
            requestData();
        }
    }
}
